// 383. 赎金信

function canConstruct(ransomNote: string, magazine: string): boolean {
  const cnt: number[] = new Array(26).fill(0);
  const a = "a".charCodeAt(0);
  for (const c of magazine) {
    cnt[c.charCodeAt(0) - a]++;
  }

  for (const ch of ransomNote) {
    if (--cnt[ch.charCodeAt(0) - a] < 0) {
      return false;
    }
  }

  return true;
}
